package com.chag.biz.userbase.service;

import com.chag.biz.userbase.dto.UserDTO;
import com.chag.biz.userbase.dto.UserSearchDTO;
import com.chag.biz.userbase.dto.UserStatusEnum;
import com.chag.framework.common.ServiceResult;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: CHAG
 * Date: 2016/6/3
 * Time: 22:38
 * User接口定义表.
 */
public interface IUserService {
    /**
     * 创建用户
     *
     * @param userDTO 用户对象
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    ServiceResult<UserDTO> createUser(UserDTO userDTO);

    /**
     * 获取用户
     *
     * @param userCode 用户编号
     * @return
     */
    @Transactional(readOnly = true)
    ServiceResult<UserDTO> getUserByCode(String userCode);

    /**
     * 根据id获取用户
     *
     * @param id 用户id
     * @return
     */
    @Transactional(readOnly = true)
    ServiceResult<UserDTO> getUserById(String id);

    /**
     * 根据企业获取用户列表
     *
     * @param orgCode 企业编码
     * @param status  用户状态
     * @return
     */
    @Transactional(readOnly = true)
    ServiceResult<List<UserDTO>> getUserByOrgCode(String orgCode, UserStatusEnum... status);

    /**
     * 获取所有用户列表
     *
     * @param status 用户状态
     * @return
     */
    @Transactional(readOnly = true)
    ServiceResult<List<UserDTO>> getAllUser(UserStatusEnum... status);

    /**
     * 根据查询条件查询用户列表
     * @param searchDTO     查询条件封装对象
     * @return
     */
    @Transactional(readOnly = true)
    ServiceResult<List<UserDTO>> getUserListBySearchDTO(UserSearchDTO searchDTO);


    /**
     * 根据查询条件查询用户数量
     * @param searchDTO     查询条件封装对象
     * @return
     */
    @Transactional(readOnly = true)
    ServiceResult<Integer> getUserCountBySearchDTO(UserSearchDTO searchDTO);

    /**
     * 更新用户
     *
     * @param userDTO 用户对象
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    ServiceResult<UserDTO> updateUser(UserDTO userDTO);

    /**
     * 更新用户名称
     *
     * @param id   用户id
     * @param name 用户名称
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    ServiceResult<UserDTO> updateUserName(String id, String name);

    /**
     * 删除用户
     *
     * @param id 用户id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    ServiceResult<Boolean> deleteUser(String id);
}
